package ferp.core.state;

import ferp.core.game.Game;
import ferp.core.game.Input;
import ferp.core.game.Settings;
import ferp.core.log.Log;
import ferp.core.player.Profile;

/**
 * User: igorgok
 * Date: 10/22/11 9:48 PM
 */
class Process extends State
{
  @Override
  public int process(Game.Listener listener, Profile profile, Game g, Settings settings, Input input) throws Game.Error
  {
    Log.debug(Log.TAG, g.player(g.player.current) + ": processing");

    // next state (by default) is getting input options if not changed to
    // something else by the process() method below
    g.set(State.gio);

    // process the current mode
    int r = g.mode().process(listener, g, settings, input);

    // reset input
    input.reset();
    // clear options
    g.options.clear();

    // save the game state
    save(profile);

    return r;
  }
}
